<#include "/classic/inc/layout.ftl"/>

<#assign title = view.title + ' - ' + options['site_name'] />
<#assign keywords = view.keywords?default(options['site_keywords']) />
<#assign description = view.description?default(options['site_description']) />

<@layout title>
    <div class="row main">
        <form id="qForm" method="post" action="score">
            <#if view??>
                <input type="hidden" name="id" value="${planId}"/>
            </#if>
            <div class="col-xs-12 col-md-9 side-left topics-show">
                <div class="infos panel-heading">
                    <h1 class="panel-title topic-title">${view.title}</h1>
                    <div class="meta inline-block">
                        复习时间：<abbr class="timeago">${reviewDate}</abbr>
                        <#if (score != '-1')>
                            复习结果：
                            <#if (score == "0")>
                                差
                            <#elseif (score == "1")>
                                中等
                            <#else>
                                优秀
                            </#if>
                        </#if>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <!-- view show -->
                <div class="topic panel panel-default fulltext">
                    <div class="content-body entry-content panel-body ">
                        <div class="markdown-body">
                            ${view.content}
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg-2 control-label">复习情况:</label>
                    <div class="col-lg-3">
                        <#if (score != '-1')>
                            <label class="col-lg-2 control-label">
                                <#if (score == "0")>
                                    差
                                <#elseif (score == "1")>
                                    中等
                                <#else>
                                    优秀
                                </#if>
                            </label>
                        <#else>
                            <select name="score" class="form-control" data-select="${score}">
                                <option value="-1">请选择</option>
                                <option value="0">差</option>
                                <option value="1">中等</option>
                                <option value="2">优秀</option>
                            </select>
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </#if>
                    </div>
                </div>

            </div>

            <#-- <div id="post-directory-module" class="col-xs-12 col-md-3  " style="background: #0E9A00;color: #1ba87e;padding: 0 0 0 15px;
         /*margin-left: -255px;*/" >
                 <div id="myCollapsibleExample"><a href="#contents" data-toggle="collapse">目录</a></div>
                 <div id="contents">
                     <section class="post-directory">
                         <dl>
                         </dl>
                     </section>
                 </div>
             </div>-->

    </div>


    <script type="text/javascript">

        $(document).ready(function () {
            $(".markdown-body h2").each(function (index) {
                $(".post-directory dl").append("<dt><a class=\"jumper\" hre=#" +
                    $(this).attr("id")
                    + ">"
                    + $(this).text()
                    + "</a></dt>");
                let children = $(this).nextUntil("h2", "h3")

                children.each(function (index) {
                    $(".post-directory dl").append("<dd><a class=\"jumper\" hre=#" +
                        $(this).attr("id")
                        + ">"
                        + "&nbsp;&nbsp;- " + $(this).text()
                        + "</a></dd>");
                });
            });

            let fixmeTop = $('#post-directory-module').offset().top - 100;       // get initial position of the element

            $(window).scroll(function () {                  // assign scroll event listener

                var currentScroll = $(window).scrollTop(); // get current position

                if (currentScroll >= fixmeTop) {           // apply position: fixed if you
                    $('#post-directory-module').css({      // scroll to that element or below it
                        top: '100px',
                        position: 'fixed',
                        width: 'inherit'
                    });
                } else {                                   // apply position: static
                    $('#post-directory-module').css({      // if you scroll above it
                        position: 'inherit',
                        width: 'inherit'
                    });
                }

            });

            $("a.jumper").on("click", function (e) {
                e.preventDefault();
                $("body, html").animate({
                    scrollTop: ($($(this).attr('hre')).offset().top - 100)
                }, 600);
            });
        });
        seajs.use(['view']);
    </script>
</@layout>
